package cn.kai.process.flow.node;

import cn.kai.process.flow.core.NodeContext;
import cn.kai.process.flow.core.Node;
import lombok.AllArgsConstructor;

/**
 * 条件节点
 Author: cKnight
 Date: 2025/1/23
 */
@AllArgsConstructor
public class ConditionNode implements Node {
    private String conditionKey;
    private ChainNode trueNode;
    private ChainNode falseNode;

    @Override
    public void execute(NodeContext context) {
        boolean flag = (boolean) context.getData(conditionKey);
        if (flag){
            trueNode.exe(context);
        }else {
            falseNode.exe(context);
        }
    }
}
